#! /bin/bash
#SQOOP_HOME=/opt/cloudera/parcels/CDH-6.2.1-1.cdh6.2.1.p0.1425774/bin/sqoop

if [ $1 != "" ]
then
	TD_DATE=$1
   
else
   TD_DATE=`date -d '1 days ago' "+%Y-%m-%d"`
fi


echo '==============开始导入==============='


# 新增和更新同步


${SQOOP_HOME} import \
--connect jdbc:mysql://106.75.33.59:3306/teach \
--username bjclass58 \
--password bjclass58_itcast \
--query "select *, '${TD_DATE}' as dt from tbh_class_time_table where 1=1 and \$CONDITIONS" \
--hcatalog-database 'ods_zhixing_04' \
--hcatalog-table 'ods_tbh_class_time_table' \
--fields-terminated-by '\t' \
-m 1
wait

${SQOOP_HOME} import \
--connect jdbc:mysql://106.75.33.59:3306/teach \
--username bjclass58 \
--password bjclass58_itcast \
--query "select *, '${TD_DATE}' as dt from student_leave_apply where 1=1 and \$CONDITIONS" \
--hcatalog-database 'zhixing_04' \
--hcatalog-table 'ods_student_leave_apply' \
--fields-terminated-by '\t' \
-m 1